#include "threadpool.hpp"
#include "Task.hpp"
#include <ctime>

int main()
{
    //ThreadPool<Task>* tp = new ThreadPool<Task>(5); 
    //tp->start(); // 创建五个线程
    cout << "process running..." << endl;
    ThreadPool<Task>::GetInstance()->start();
    srand(time(nullptr));
    int len = opsum.size();
    while(true)
    {
        // 1.构建任务
        int x = rand() % 10 + 1;
        usleep(10);
        int y = rand() % 5;
        char op = opsum[rand() % len];
        Task t(x, y, op);
        // 2.交给线程池处理
        ThreadPool<Task>::GetInstance()->push(t);
        cout << "main thread make task: " << t.GetTask() << endl;
        sleep(1);
    }
}

